/*
 *  Copyright 2008-2009 NVIDIA Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */


#pragma once

#include <vector>

#include <sfv/format.h>
//#include <sfv/exception.h>

namespace sfv
{
  template <typename T>
  class array1d : public std::vector<T>
  {
      private:
          typedef typename std::vector<T> Parent;
  
      public:
          typedef sfv::array1d_format format;

          /*! equivalent container type
           */
          typedef typename sfv::array1d<T> container;
          
          typedef typename Parent::size_type  size_type;
          typedef typename Parent::value_type value_type;
  
          array1d(void) : Parent() {}

          explicit array1d(size_type n)
              : Parent()
          {
              if(n > 0)
              {
                  Parent::resize(n);
              }
          }
          
          array1d(size_type n, const value_type &value) 
            : Parent(n, value) {}

          //template<typename Array>
          //  array1d(const Array& a)
          //  : Parent(a.begin(), a.end()) {}

          template<typename InputIterator>
            array1d(InputIterator first, InputIterator last)
            : Parent(first, last) {}

          template<typename Array>
            array1d &operator=(const Array& a)
            { Parent::assign(a.begin(), a.end()); return *this; }

          // TODO specialize resize()

	  // Deallocate memory
	  void deallocate( void )
	  {
	    Parent::resize(0);
	  }
  };
  
} // end namespace sfv

#include <sfv/detail/array1d.inl>

